<h1>Listing items</h1>

<table>
  <tr>
    <th>Item Category</th>
    <th>Item name</th>
    <th>Brand name</th>
    <th>Item price</th>
    <th>Item detail</th>
    <th>Item quantity</th>
    <th>Item boughtdate</th>
    <th>Item expiredate</th>
    <th>How many time left</th>
  </tr>

<% for item in @items %>
  <tr>
    <td><%=h item.category.category_name %> || <%=h item.subcategory.subcategory_name %></td>
    <td><%=h item.item_name %></td>
    <td><%=h item.brand.brand_name %></td>
    <td><%=h item.item_price %></td>
    <td><%=h item.item_detail %></td>
    <td><%=h item.item_quantity %></td>
    <td><%=h item.item_boughtdate %></td>
    <td><%=h item.item_expiredate %></td>
    <td><%=h distance_of_time_in_words(Time.now, item.item_expiredate, true ) %></td>
    <td><%= link_to 'Show', item %></td>
    <td><%= link_to 'Edit', edit_item_path(item) %></td>
    <td><%= link_to 'Destroy', item, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New item', new_item_path %>
